<div style="font-weight:bold;font-size:20px;margin-top: 20px;">${serialNumber}、人口结构</div>
<div style="text-indent: 2em;font-size:20px;margin-top: 20px;line-height: 35px;">
    根据人物画像能力库内的人口信息，得出海南省当前人口性别及年龄结构信息如下图所示：
</div>
<div id="myecharts21" style="width: 1000px; height: 500px; margin: 0 auto; margin-top: 20px"></div>
<div style="margin-top: 10px; text-align: center; font-size: 20px;">图21 海南省人口结构</div>
<script>
    (function () {

        $(document).ready(function(){
            // 人口结构
            var data = ${ageStructureDataList}
            var result21 = [
                // {
                //     type: '男性',
                //     datas: [
                        {label: '0~4岁', count: 195},
                        {label: '4~10岁', count: 55},
                        {label: '10~16岁', count: 641},
                        {label: '16~34岁', count: 5},
                        {label: '34~50岁', count: 115},
                        {label: '50~100岁', count: 115},
                //     ]
                // },
                // {
                //     type: '女性',
                //     datas: [
                //         {label: '0~4岁', count: 44},
                //         {label: '4~10岁', count: 88},
                //         {label: '10~16岁', count: 99},
                //         {label: '16~34岁', count: 115},
                //         {label: '34~50岁', count: 115},
                //         {label: '50~100岁', count: 115},
                //     ]
                // },
            ]
            // var series = [], xCategory= []
            var myecharts21 = echarts.init(document.getElementById("myecharts21"));
            // $.each(result21,function(index,item) {
            //     var obj = { name: '', type: 'bar', data: [] }
            //     var count = $.map(item.datas, function(n, i){ return n.count; })
            //     if(index===0) {
            //         xCategory = $.map(item.datas, function(n, i){ return n.label; })
            //     }
            //     obj.name = item.type;
            //     obj.data = count;
            //     series.push(obj);
            // });
            // var option21 = getOptionBar(true, xCategory, series, '海南省人员结构', ['#4b91ff', '#f2637b'])
            var ageMap = {
                "A01": "0-6岁",
                "A02": "7-12岁",
                "A03": "13-17岁",
                "A04": "18-45岁",
                "A05": "46-69岁",
                "A06": "70及以上"
            }
            var barXAxisData21 = $.map(data, function(n, i){ return ageMap[n.ageGrpCd]  });
            var countValues21 = $.map(data, function(n, i){ return n.pmntPopuNum });
            var option21 = getOptionBar(false, barXAxisData21, countValues21, '海南省人员结构')
            myecharts21.setOption(option21);
        });
        function getOptionBar(isMultipleYAxes, barXAxisData, countValues, title, color) {
            // isMultipleYAxes 是否多y轴
            var series = !isMultipleYAxes? [ { type: "bar", data: countValues } ] : countValues
            var legend = isMultipleYAxes? $.map(countValues, function(n, i){ return n.name; }): []
            var option = {
                title: {
                    text: title,
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "shadow",
                    },
                },
                color: color?color: ['#4b91ff'],
                legend: {
                    right: '4%',
                    data: legend,
                },
                grid: {
                    left: "3%",
                    right: "4%",
                    bottom: "3%",
                    containLabel: true,
                },
                xAxis: {
                    type: "category",
                    data: barXAxisData,
                },
                yAxis: {
                    type: "value",
                    boundaryGap: [0, 0.01],
                    axisLabel: {
                        fontSize: 14,
                        show: true,
                        formatter: function(params) {
                            var result = ''
                            result = params / 10000
                            if (params > 1000) {
                                return result + '万'
                            } else {
                                return params
                            }
                        },
                    },
                },
                series: series
            }
            return option
        }
    })()
</script>